<template>
	<!-- 企业经营情况登记表 -->
	<view>
		<u-form class="form" :model="form" ref="uForm" label-width="180" label-position="left">
			<u-form-item label="走访日期" prop="visitTime">
				<u-input v-model="form.visitTime" border trim disabled @click="showVisitTime=true" />
				<u-calendar v-model="showVisitTime" mode="date" @change="changeVisitTime"></u-calendar>
			</u-form-item>
			<u-form-item label="联络员" prop="visitBy" required>
				<u-input v-model="form.visitBy" border trim disabled />
			</u-form-item>
			<u-form-item label=" ">
				<u-button type="primary" size="mini" @click="showCompanyDialog = true">查询申报企业</u-button>
			</u-form-item>
			<u-form-item label="单位名称" prop="companyName" required>
				<u-input v-model="form.companyName" border trim />
			</u-form-item>
			<u-form-item label="许可证号" prop="xukezhenghao">
				<u-input v-model="form.xukezhenghao" border trim />
			</u-form-item>
			<u-form-item label="联系人" prop="contactName">
				<u-input v-model="form.contactName" border trim />
			</u-form-item>
			<u-form-item label="联系电话" prop="contactTel">
				<u-input v-model="form.contactTel" border trim />
			</u-form-item>
			<u-form-item label="单位地址" prop="companyAddress">
				<u-input v-model="form.companyAddress" border trim />
			</u-form-item>
			<u-form-item prop="cityText" label="所属城市" required>
				<u-input type="select" border trim v-model="form.cityText" placeholder="选择单位所在城市"
					@click="showCity = true" />
				<u-select v-model="showCity" mode="mutil-column-auto" :list="cityOptions" value-name="bianma"
					label-name="mingcheng" @confirm="confirmCity">
				</u-select>
			</u-form-item>
			<u-form-item label="管理模式" prop="guanlimoshi">
				<u-radio-group v-model="form.guanlimoshi">
					<u-radio v-for="(item, index) in guanlimoshiOptions" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="公司名称" prop="guanlimoshiname" v-show="form.guanlimoshi != 0">
				<u-input v-model="form.guanlimoshiname" />
			</u-form-item>
			
			<u-form-item label="管理团队" prop="guanlituandui">
				<u-checkbox-group @change="guanlituanduiChange">
					<u-checkbox 
						v-model="item.checked" 
						v-for="(item, index) in guanlituanduiOptions" :key="index" 
						:name="item.dictValue"
					>{{item.dictLabel}}</u-checkbox>
				</u-checkbox-group>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="入会情况" prop="itemkey1">
				<u-radio-group v-model="form.itemkey1">
					<u-radio v-for="(item, index) in itemkey1Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="协会名称" prop="itemname1" v-show="form.itemkey1 != 0">
				<u-input v-model="form.itemname1" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime1" v-show="form.itemkey1 != 0">
				<u-input v-model="form.itemetime1" @click="itemetime1Show = true" />
				<u-calendar v-model="itemetime1Show" mode="date" :max-date="maxDate" @change="itemetime1Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="人员体检" prop="itemkey2">
				<u-radio-group v-model="form.itemkey2">
					<u-radio v-for="(item, index) in itemkey2Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="医院名称" prop="itemname2">
				<u-input v-model="form.itemname2" />
			</u-form-item>
			<u-form-item label="人数" prop="itemother2">
				<u-input v-model="form.itemother2" />
			</u-form-item>
			<u-form-item label="办证数" prop="itemremark2">
				<u-input v-model="form.itemremark2" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime2">
				<u-input v-model="form.itemetime2" @click="itemetime2Show = true" />
				<u-calendar v-model="itemetime2Show" mode="date" :max-date="maxDate" @change="itemetime2Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="人员培训" prop="itemkey3">
				<u-radio-group v-model="form.itemkey3">
					<u-radio v-for="(item, index) in itemkey3Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="培训机构" prop="itemname3" v-show="form.itemkey3 != 0">
				<u-input v-model="form.itemname3" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime3" v-show="form.itemkey3 != 0">
				<u-input v-model="form.itemetime3" @click="itemetime3Show = true" />
				<u-calendar v-model="itemetime3Show" mode="date" :max-date="maxDate" @change="itemetime3Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="色标管理" prop="itemkey4">
				<u-radio-group v-model="form.itemkey4">
					<u-radio v-for="(item, index) in itemkey4Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname4" v-show="form.itemkey4 != 0">
				<u-input v-model="form.itemname4" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime4" v-show="form.itemkey4 != 0">
				<u-input v-model="form.itemetime4" @click="itemetime4Show = true" />
				<u-calendar v-model="itemetime4Show" mode="date" :max-date="maxDate" @change="itemetime4Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="食材溯源" prop="itemkey5">
				<u-radio-group v-model="form.itemkey5">
					<u-radio v-for="(item, index) in itemkey5Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="平台名称" prop="itemname5" v-show="form.itemkey5 != 0">
				<u-input v-model="form.itemname5" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime5" v-show="form.itemkey5 != 0">
				<u-input v-model="form.itemetime5" @click="itemetime5Show = true" />
				<u-calendar v-model="itemetime5Show" mode="date" :max-date="maxDate" 
				@change="itemetime5Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="第三方自查" prop="itemkey6">
				<u-radio-group v-model="form.itemkey6">
					<u-radio v-for="(item, index) in itemkey6Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname6" v-show="form.itemkey6 != 0">
				<u-input v-model="form.itemname6" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime6" v-show="form.itemkey6 != 0">
				<u-input v-model="form.itemetime6" @click="itemetime6Show = true" />
				<u-calendar v-model="itemetime6Show" mode="date" :max-date="maxDate" 
				@change="itemetime6Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="食安责任险" prop="itemkey7">
				<u-radio-group v-model="form.itemkey7">
					<u-radio v-for="(item, index) in itemkey7Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname7" v-show="form.itemkey7 != 0">
				<u-input v-model="form.itemname7" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime7" v-show="form.itemkey7 != 0">
				<u-input v-model="form.itemetime7" @click="itemetime7Show = true" />
				<u-calendar v-model="itemetime7Show" mode="date" :max-date="maxDate" 
				@change="itemetime7Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="体系认证" prop="itemkey8">
				<u-radio-group v-model="form.itemkey8">
					<u-radio v-for="(item, index) in itemkey8Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname8" v-show="form.itemkey8 != 0">
				<u-input v-model="form.itemname8" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime8" v-show="form.itemkey8 != 0">
				<u-input v-model="form.itemetime8" @click="itemetime8Show = true" />
				<u-calendar v-model="itemetime8Show" mode="date" :max-date="maxDate" 
				@change="itemetime8Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="消杀" prop="itemkey9">
				<u-radio-group v-model="form.itemkey9">
					<u-radio v-for="(item, index) in itemkey9Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname9" v-show="form.itemkey9 != 0">
				<u-input v-model="form.itemname9" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime9" v-show="form.itemkey9 != 0">
				<u-input v-model="form.itemetime9" @click="itemetime9Show = true" />
				<u-calendar v-model="itemetime9Show" mode="date" :max-date="maxDate" 
				@change="itemetime9Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="烟道清洗" prop="itemkey10">
				<u-radio-group v-model="form.itemkey10">
					<u-radio v-for="(item, index) in itemkey10Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname10" v-show="form.itemkey10 != 0">
				<u-input v-model="form.itemname10" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime10" v-show="form.itemkey10 != 0">
				<u-input v-model="form.itemetime10" @click="itemetime10Show = true" />
				<u-calendar v-model="itemetime10Show" mode="date" :max-date="maxDate" 
				@change="itemetime10Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="检验检测" prop="itemkey11">
				<u-radio-group v-model="form.itemkey11">
					<u-radio v-for="(item, index) in itemkey11Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname11" v-show="form.itemkey11 != 0">
				<u-input v-model="form.itemname11" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime11" v-show="form.itemkey11 != 0">
				<u-input v-model="form.itemetime11" @click="itemetime11Show = true" />
				<u-calendar v-model="itemetime11Show" mode="date" :max-date="maxDate" 
				@change="itemetime11Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="水质检测" prop="itemkey12">
				<u-radio-group v-model="form.itemkey12">
					<u-radio v-for="(item, index) in itemkey12Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname12" v-show="form.itemkey12 != 0">
				<u-input v-model="form.itemname12" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime12" v-show="form.itemkey12 != 0">
				<u-input v-model="form.itemetime12" @click="itemetime12Show = true" />
				<u-calendar v-model="itemetime12Show" mode="date" :max-date="maxDate" 
				@change="itemetime12Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="空气检测" prop="itemkey13">
				<u-radio-group v-model="form.itemkey13">
					<u-radio v-for="(item, index) in itemkey13Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname13" v-show="form.itemkey13 != 0">
				<u-input v-model="form.itemname13" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime13" v-show="form.itemkey13 != 0">
				<u-input v-model="form.itemetime13" @click="itemetime13Show = true" />
				<u-calendar v-model="itemetime13Show" mode="date" :max-date="maxDate" 
				@change="itemetime13Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="装修设计" prop="itemkey14">
				<u-radio-group v-model="form.itemkey14">
					<u-radio v-for="(item, index) in itemkey14Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname14" v-show="form.itemkey14 != 0">
				<u-input v-model="form.itemname14" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime14" v-show="form.itemkey14 != 0">
				<u-input v-model="form.itemetime14" @click="itemetime14Show = true" />
				<u-calendar v-model="itemetime14Show" mode="date" :max-date="maxDate" 
				@change="itemetime14Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="食品服装" prop="itemkey15">
				<u-radio-group v-model="form.itemkey15">
					<u-radio v-for="(item, index) in itemkey15Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname15" v-show="form.itemkey15 != 0">
				<u-input v-model="form.itemname15" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime15" v-show="form.itemkey15 != 0">
				<u-input v-model="form.itemetime15" @click="itemetime15Show = true" />
				<u-calendar v-model="itemetime15Show" mode="date" :max-date="maxDate" 
				@change="itemetime15Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="明厨亮灶" prop="itemkey16">
				<u-radio-group v-model="form.itemkey16">
					<u-radio v-for="(item, index) in itemkey16Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname16" v-show="form.itemkey16 != 0">
				<u-input v-model="form.itemname16" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime16" v-show="form.itemkey16 != 0">
				<u-input v-model="form.itemetime16" @click="itemetime16Show = true" />
				<u-calendar v-model="itemetime16Show" mode="date" :max-date="maxDate" 
				@change="itemetime16Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="营养膳食" prop="itemkey17">
				<u-radio-group v-model="form.itemkey17">
					<u-radio v-for="(item, index) in itemkey17Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname17" v-show="form.itemkey17 != 0">
				<u-input v-model="form.itemname17" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime17" v-show="form.itemkey17 != 0">
				<u-input v-model="form.itemetime17" @click="itemetime17Show = true" />
				<u-calendar v-model="itemetime17Show" mode="date" :max-date="maxDate" 
				@change="itemetime17Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="包装设计" prop="itemkey18">
				<u-radio-group v-model="form.itemkey18">
					<u-radio v-for="(item, index) in itemkey18Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname18" v-show="form.itemkey18 != 0">
				<u-input v-model="form.itemname18" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime18" v-show="form.itemkey18 != 0">
				<u-input v-model="form.itemetime18" @click="itemetime18Show = true" />
				<u-calendar v-model="itemetime18Show" mode="date" :max-date="maxDate" 
				@change="itemetime18Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="设施设备" prop="itemkey19">
				<u-radio-group v-model="form.itemkey19">
					<u-radio v-for="(item, index) in itemkey19Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname19" v-show="form.itemkey19 != 0">
				<u-input v-model="form.itemname19" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime19" v-show="form.itemkey19 != 0">
				<u-input v-model="form.itemetime19" @click="itemetime19Show = true" />
				<u-calendar v-model="itemetime19Show" mode="date" :max-date="maxDate" 
				@change="itemetime19Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="人民调解" prop="itemkey20">
				<u-radio-group v-model="form.itemkey20">
					<u-radio v-for="(item, index) in itemkey20Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname20" v-show="form.itemkey20 != 0">
				<u-input v-model="form.itemname20" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime20" v-show="form.itemkey20 != 0">
				<u-input v-model="form.itemetime20" @click="itemetime20Show = true" />
				<u-calendar v-model="itemetime20Show" mode="date" :max-date="maxDate" 
				@change="itemetime20Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="视频拍摄" prop="itemkey21">
				<u-radio-group v-model="form.itemkey21">
					<u-radio v-for="(item, index) in itemkey21Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname21" v-show="form.itemkey21 != 0">
				<u-input v-model="form.itemname21" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime21" v-show="form.itemkey21 != 0">
				<u-input v-model="form.itemetime21" @click="itemetime21Show = true" />
				<u-calendar v-model="itemetime21Show" mode="date" :max-date="maxDate" 
				@change="itemetime21Change"></u-calendar>
			</u-form-item>
			
			<view class="split-line"></view>
			<u-form-item label="礼盒包装" prop="itemkey22">
				<u-radio-group v-model="form.itemkey22">
					<u-radio v-for="(item, index) in itemkey22Options" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="企业名称" prop="itemname22" v-show="form.itemkey22 != 0">
				<u-input v-model="form.itemname22" />
			</u-form-item>
			<u-form-item label="截止日期" prop="itemetime22" v-show="form.itemkey22 != 0">
				<u-input v-model="form.itemetime22" @click="itemetime22Show = true" />
				<u-calendar v-model="itemetime22Show" mode="date" :max-date="maxDate" 
				@change="itemetime22Change"></u-calendar>
			</u-form-item>
			
			<!-- <u-form-item label="上传附件" prop="images">
				<u-upload ref="upload1"
					:action="uploadAction" 
					:file-list="fileList"
					:header="uploadHeader"
					:max-size="2 * 1024 * 1024" 
					max-count="9"
					@on-choose-complete="chooseComplete"
					@on-success="uploadSuccess"
					@on-error="uploadError"
					@on-uploaded="uploaded"
				></u-upload>
			</u-form-item> -->
			
			<view class="split-line"></view>
			<u-form-item label="配合度" prop="degree">
				<u-radio-group v-model="form.degree">
					<u-radio v-for="(item, index) in degreeOptions" :key="index" :name="item.dictValue"
						:disabled="item.disabled">
						{{item.dictLabel}}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<view class="split-line"></view>
			<u-form-item prop="remark" label="备注">
				<u-input type="textarea" autoHeight placeholder="备注" confirmType="done"
					v-model="form.remark" border trim/>
			</u-form-item>
		</u-form>

		<u-button type="primary" @click="submit" :disabled="disabled" :loading="loading">提交</u-button>
		
		<u-popup v-model="showCompanyDialog" mode="bottom" border-radius="16" closeable height="600px">
			<view style="margin-top: 20px;">
				<u-search style="padding: 20px 20px;" placeholder="请输入关键字" v-model="query.companyName" @search="getCompanyList" @custom="getCompanyList"></u-search>
				
				<scroll-view scroll-y="true" style="height: 460px;">
					<view style="padding: 0px 12rpx;">
						<u-empty v-if="companyList.length == 0" mode="list"></u-empty>
						<view v-else class="">
							<u-table align="left" padding="10rpx 20rpx" font-size="32rpx">
								<u-tr v-for="item in companyList" :key="item.id">
									<u-td>{{item.username}}</u-td>
									<u-td width="40px"><u-button type="primary" size="mini" @click="chooseCompany(item)">选择</u-button></u-td>
								</u-tr>
							</u-table>
						</view>
					</view>
				</scroll-view>
				
				<u-button type="info" @click="showCompanyDialog = false">关闭</u-button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import config from '@/app.config.js'
	export default {
		data() {
			let form = {
				id: null,
				visitId: vk.getVuex('$user.userInfo.userId'),
				visitBy: vk.getVuex('$user.userInfo.nickName'),
				visitTime: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd"),
				companyId: null,
				companyName: null,
				xukezhenghao: null,
				contactName: null,
				contactTel: null,
				companyAddress: null,
				shi: null,
				qu: null,
				guanlimoshi: '0',
				guanlimoshiname: null,
				guanlituandui: [],
				guanlituanduiname: null,
				itemkey1: '0',
				itemname1: null,
				itemother1: null,
				itemstime1: null,
				itemetime1: null,
				itemkey2: '0',
				itemname2: null,
				itemother2: null,
				itemremark2: null,
				itemstime2: null,
				itemetime2: null,
				itemkey3: '0',
				itemname3: null,
				itemother3: null,
				itemstime3: null,
				itemetime3: null,
				itemkey4: '0',
				itemname4: null,
				itemother4: null,
				itemstime4: null,
				itemetime4: null,
				itemkey5: '0',
				itemname5: null,
				itemother5: null,
				itemstime5: null,
				itemetime5: null,
				itemkey6: '0',
				itemname6: null,
				itemother6: null,
				itemstime6: null,
				itemetime6: null,
				itemkey7: '0',
				itemname7: null,
				itemother7: null,
				itemstime7: null,
				itemetime7: null,
				itemkey8: '0',
				itemname8: null,
				itemother8: null,
				itemstime8: null,
				itemetime8: null,
				itemkey9: '0',
				itemname9: null,
				itemother9: null,
				itemstime9: null,
				itemetime9: null,
				itemkey10: '0',
				itemname10: null,
				itemother10: null,
				itemstime10: null,
				itemetime10: null,
				itemkey11: '0',
				itemname11: null,
				itemother11: null,
				itemstime11: null,
				itemetime11: null,
				itemkey12: '0',
				itemname12: null,
				itemother12: null,
				itemstime12: null,
				itemetime12: null,
				itemkey13: '0',
				itemname13: null,
				itemother13: null,
				itemstime13: null,
				itemetime13: null,
				itemkey14: '0',
				itemname14: null,
				itemother14: null,
				itemstime14: null,
				itemetime14: null,
				itemkey15: '0',
				itemname15: null,
				itemother15: null,
				itemstime15: null,
				itemetime15: null,
				itemkey16: '0',
				itemname16: null,
				itemother16: null,
				itemstime16: null,
				itemetime16: null,
				itemkey17: '0',
				itemname17: null,
				itemother17: null,
				itemstime17: null,
				itemetime17: null,
				itemkey18: '0',
				itemname18: null,
				itemother18: null,
				itemstime18: null,
				itemetime18: null,
				itemkey19: '0',
				itemname19: null,
				itemother19: null,
				itemstime19: null,
				itemetime19: null,
				itemkey20: '0',
				itemname20: null,
				itemother20: null,
				itemstime20: null,
				itemetime20: null,
				itemkey21: '0',
				itemname21: null,
				itemother21: null,
				itemstime21: null,
				itemetime21: null,
				itemkey22: '0',
				itemname22: null,
				itemother22: null,
				itemstime22: null,
				itemetime22: null,
				images: null,
				degree: '0',
				remark: null,
				status: '0',
				createBy: null,
				createTime: null,
				updateBy: null,
				updateTime: null,
			}
			return {
				disabled: false, // 提交中
				loading: false, // 提交中
				
				id: '',
				companyIn: null, // 接收评分列表页传入的企业信息
				
				showVisitTime: false,
				maxDate: '2050-12-31', // 日历的最大可选日期
				
				itemetime1Show: false,
				itemetime2Show: false,
				itemetime3Show: false,
				itemetime4Show: false,
				itemetime5Show: false,
				itemetime6Show: false,
				itemetime7Show: false,
				itemetime8Show: false,
				itemetime9Show: false,
				itemetime10Show: false,
				itemetime11Show: false,
				itemetime12Show: false,
				itemetime13Show: false,
				itemetime14Show: false,
				itemetime15Show: false,
				itemetime16Show: false,
				itemetime17Show: false,
				itemetime18Show: false,
				itemetime19Show: false,
				itemetime20Show: false,
				itemetime21Show: false,
				itemetime22Show: false,

				// 管理模式字典
				guanlimoshiOptions: [],
				// 管理团队字典
				guanlituanduiOptions: [],
				// 入会情况 0无 1有 score_have_not字典
				itemkey1Options: [],
				// 人员体检 人员体检 0省证 1市证 score_tijian字典
				itemkey2Options: [],
				// 人员培训 0自主 1外部 score_peixun字典
				itemkey3Options: [],
				// 色标管理 0无 1自主 2第三方 score_sebiao字典
				itemkey4Options: [],
				// 食材溯源 0食安辽宁码 1自有平台 score_suyuan字典
				itemkey5Options: [],
				// 第三方自查 0无 1有 score_have_not字典
				itemkey6Options: [],
				// 食安责任险 0无 1有 score_have_not字典
				itemkey7Options: [],
				// 体系认证 0无 1有 score_have_not字典
				itemkey8Options: [],
				// 消杀 0无 1有 score_have_not字典
				itemkey9Options: [],
				// 烟道清洗 0无 1有 score_have_not字典
				itemkey10Options: [],
				// 检验检测 0无 1有 score_have_not字典
				itemkey11Options: [],
				// 水质检测 0无 1有 score_have_not字典
				itemkey12Options: [],
				// 空气检测 0无 1有 score_have_not字典
				itemkey13Options: [],
				// 装修设计 0无 1有 score_have_not字典
				itemkey14Options: [],
				// 食品服装 0无 1有 score_have_not字典
				itemkey15Options: [],
				// 明厨亮灶 0无 1有 score_have_not字典
				itemkey16Options: [],
				// 营养膳食 0无 1有 score_have_not字典
				itemkey17Options: [],
				// 包装设计 0无 1有 score_have_not字典
				itemkey18Options: [],
				// 设施设备 0无 1有 score_have_not字典
				itemkey19Options: [],
				// 人民调解 0无 1有 score_have_not字典
				itemkey20Options: [],
				// 视频拍摄 0无 1有 score_have_not字典
				itemkey21Options: [],
				// 礼盒包装 0无 1有 score_have_not字典
				itemkey22Options: [],
				
				cityOptions: getApp().globalData.cityOptions,
				showCity: false,
				
				// 配合度字典
				degreeOptions: [],

				uploadAction: this.$api.uploadAction,
				fileList: [],
				uploadHeader: {},
				
				showCompanyDialog: false,
				companyList: [],
				query: {
					companyName: null
				},

				form,
				rules: {
					companyName: [{
						required: true,
						message: '请输入企业名称',
						trigger: ['blur', 'change']
					}],
					visitBy: [{
						required: true,
						message: '联络员为空，请检查是否尚未登录',
						trigger: ['blur', 'change']
					}]
				}
			}
		},
		onLoad(options) {
			// console.log('globalData', getApp().globalData);
			this.initPage(options)
		},
		// 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			guanlituanduiChange(e) {
				this.form.guanlituandui = e;
			},
			changeVisitTime(e){
				this.form.visitTime = e.result;
			},
			itemetime1Change(e) { this.form.itemetime1 = e.result; },
			itemetime2Change(e) { this.form.itemetime2 = e.result; },
			itemetime3Change(e) { this.form.itemetime3 = e.result; },
			itemetime4Change(e) { this.form.itemetime4 = e.result; },
			itemetime5Change(e) { this.form.itemetime5 = e.result; },
			itemetime6Change(e) { this.form.itemetime6 = e.result; },
			itemetime7Change(e) { this.form.itemetime7 = e.result; },
			itemetime8Change(e) { this.form.itemetime8 = e.result; },
			itemetime9Change(e) { this.form.itemetime9 = e.result; },
			itemetime10Change(e) { this.form.itemetime10 = e.result; },
			itemetime11Change(e) { this.form.itemetime11 = e.result; },
			itemetime12Change(e) { this.form.itemetime12 = e.result; },
			itemetime13Change(e) { this.form.itemetime13 = e.result; },
			itemetime14Change(e) { this.form.itemetime14 = e.result; },
			itemetime15Change(e) { this.form.itemetime15 = e.result; },
			itemetime16Change(e) { this.form.itemetime16 = e.result; },
			itemetime17Change(e) { this.form.itemetime17 = e.result; },
			itemetime18Change(e) { this.form.itemetime18 = e.result; },
			itemetime19Change(e) { this.form.itemetime19 = e.result; },
			itemetime20Change(e) { this.form.itemetime20 = e.result; },
			itemetime21Change(e) { this.form.itemetime21 = e.result; },
			itemetime22Change(e) { this.form.itemetime22 = e.result; },
			// 管理模式字典翻译
			guanlimoshiFormat(row, column) {
				return this.selectDictLabel(this.guanlimoshiOptions, row.guanlimoshi);
			},
			// 管理团队字典翻译
			guanlituanduiFormat(row, column) {
				return this.selectDictLabel(this.guanlituanduiOptions, row.guanlituandui);
			},
			// 入会情况 0无 1有 score_have_not字典翻译
			itemkey1Format(row, column) {
				return this.selectDictLabel(this.itemkey1Options, row.itemkey1);
			},
			// 人员体检 0省证 1市证 score_tijian字典翻译
			itemkey2Format(row, column) {
				return this.selectDictLabel(this.itemkey2Options, row.itemkey2);
			},
			// 人员培训 0自主 1外部 score_peixun字典翻译
			itemkey3Format(row, column) {
				return this.selectDictLabel(this.itemkey3Options, row.itemkey3);
			},
			// 色标管理 0无 1自主 2第三方 score_sebiao字典翻译
			itemkey4Format(row, column) {
				return this.selectDictLabel(this.itemkey4Options, row.itemkey4);
			},
			// 食材溯源 0食安辽宁码 1自有平台 score_suyuan字典翻译
			itemkey5Format(row, column) {
				return this.selectDictLabel(this.itemkey5Options, row.itemkey5);
			},
			// 第三方自查 0无 1有 score_have_not字典翻译
			itemkey6Format(row, column) {
				return this.selectDictLabel(this.itemkey6Options, row.itemkey6);
			},
			// 食安责任险 0无 1有 score_have_not字典翻译
			itemkey7Format(row, column) {
				return this.selectDictLabel(this.itemkey7Options, row.itemkey7);
			},
			// 体系认证 0无 1有 score_have_not字典翻译
			itemkey8Format(row, column) {
				return this.selectDictLabel(this.itemkey8Options, row.itemkey8);
			},
			// 消杀 0无 1有 score_have_not字典翻译
			itemkey9Format(row, column) {
				return this.selectDictLabel(this.itemkey9Options, row.itemkey9);
			},
			// 烟道清洗 0无 1有 score_have_not字典翻译
			itemkey10Format(row, column) {
				return this.selectDictLabel(this.itemkey10Options, row.itemkey10);
			},
			// 检验检测 0无 1有 score_have_not字典翻译
			itemkey11Format(row, column) {
				return this.selectDictLabel(this.itemkey11Options, row.itemkey11);
			},
			// 水质检测 0无 1有 score_have_not字典翻译
			itemkey12Format(row, column) {
				return this.selectDictLabel(this.itemkey12Options, row.itemkey12);
			},
			// 空气检测 0无 1有 score_have_not字典翻译
			itemkey13Format(row, column) {
				return this.selectDictLabel(this.itemkey13Options, row.itemkey13);
			},
			// 装修设计 0无 1有 score_have_not字典翻译
			itemkey14Format(row, column) {
				return this.selectDictLabel(this.itemkey14Options, row.itemkey14);
			},
			// 食品服装 0无 1有 score_have_not字典翻译
			itemkey15Format(row, column) {
				return this.selectDictLabel(this.itemkey15Options, row.itemkey15);
			},
			// 明厨亮灶 0无 1有 score_have_not字典翻译
			itemkey16Format(row, column) {
				return this.selectDictLabel(this.itemkey16Options, row.itemkey16);
			},
			// 营养膳食 0无 1有 score_have_not字典翻译
			itemkey17Format(row, column) {
				return this.selectDictLabel(this.itemkey17Options, row.itemkey17);
			},
			// 包装设计 0无 1有 score_have_not字典翻译
			itemkey18Format(row, column) {
				return this.selectDictLabel(this.itemkey18Options, row.itemkey18);
			},
			// 设施设备 0无 1有 score_have_not字典翻译
			itemkey19Format(row, column) {
				return this.selectDictLabel(this.itemkey19Options, row.itemkey19);
			},
			// 人民调解 0无 1有 score_have_not字典翻译
			itemkey20Format(row, column) {
				return this.selectDictLabel(this.itemkey20Options, row.itemkey20);
			},
			// 视频拍摄 0无 1有 score_have_not字典翻译
			itemkey21Format(row, column) {
				return this.selectDictLabel(this.itemkey21Options, row.itemkey21);
			},
			// 礼盒包装 0无 1有 score_have_not字典翻译
			itemkey22Format(row, column) {
				return this.selectDictLabel(this.itemkey22Options, row.itemkey22);
			},
			
			initPage(options = {}) {
				// 有id，是从list进来的
				if(options.id){
					this.id = options.id;
				}
				else{
					// 有传入数据，是从评分页面进来的
					const eventChannel = this.getOpenerEventChannel();
					// 监听data事件，获取上一页面通过eventChannel.emit传送到当前页面的数据
					if (eventChannel.on) {
						eventChannel.on('data', (data) => {
							this.companyIn = data
						});
					}
				}
				
				// 校验token没必要。并且，若登录，传入数据就丢失了
				if(!this.$util.getToken()){
					this.$util.toLogin(()=>this.initPage(options))
				}
				
				let tokenStr = this.$util.getToken() ? 'Bearer ' + this.$util.getToken() : '';
				this.uploadHeader = {
					'Authorization': tokenStr
				}
				
				uni.$once('dict-init', () => {
					this.getAllDicts();
				})
				this.getAllDicts();
				
				if(this.id || this.companyIn){
					this.getData();
				}else{
					// 新增，先取缓存
					if(!!vk.getVuex('$lhfj.business')){
						this.form = vk.getVuex('$lhfj.business')
					}
				}
			},
			getAllDicts(){
				this.getDicts("score_guanlimoshi", 'guanlimoshiOptions');
				this.getDicts("score_guanlituandui", 'guanlituanduiOptions');
				this.getDicts("score_have_not", 'itemkey1Options');
				this.getDicts("score_tijian", 'itemkey2Options');
				this.getDicts("score_peixun", 'itemkey3Options');
				this.getDicts("score_sebiao", 'itemkey4Options');
				this.getDicts("score_suyuan", 'itemkey5Options');
				for(let i=6; i<=22; i++){
					this.getDicts("score_have_not", 'itemkey'+i+'Options');
				}
				this.getDicts("score_degree", 'degreeOptions');
			},
			// 根据字典类型查询字典数据信息
			getDicts(dictType, optName) {
				this[optName] = vk.pubfn.copyObject(getApp().globalData[dictType])
			},
			selectDictLabel(options, dictValue){
				return options.find(item => item.dictValue = dictValue).dictLabel;
			},
			getData() {
				// 有id，是列表点修改进入的；没有id，需要查数据库
				let url = '';
				let data = null;
				if(this.id){
					url = this.$api.BusinessInfo + this.id;
				}else if(this.companyIn){
					url = this.$api.BusinessInfo2;
					data = {
						companyId: this.companyIn.companyId
					}
				}else{
					vk.alert('参数异常');
					return
				}
				// console.log('取business详情',url, data);
				this.$util.request(url, data)
					.then(res => {
						if(res.data){
							this.form = res.data
							if (this.form.guanlituandui && this.form.guanlituandui.length > 0) {
								this.form.guanlituandui = this.form.guanlituandui.split(',');
							}else this.form.guanlituandui = [];
							// this.fileList = this.form.images.split(',').map(item => {return {url: this.$resource.imageDomain + item}})
							
							if(this.id && this.form.guanlituandui.length>0 && this.guanlituanduiOptions.length > 0){
								this.guanlituanduiOptions = this.guanlituanduiOptions.map(item => ({...item, checked: this.form.guanlituandui.indexOf(item.dictValue) >= 0}))
							}
							
							let shi = this.cityOptions.find(item => item.mingcheng == this.form.shi)
							let qu = shi.children.find(item => item.mingcheng == this.form.qu)
							this.form.cityText = shi.mingcheng + ' ' + qu.mingcheng;
						}else{
							// 没查询到结果，但有传入的企业信息，说明是评分列表传入的，需将企业信息写入页面
							if(!!this.companyIn){
								// 将 前端传入的数据 的属性赋值给 form
								vk.pubfn.objectAssign(this.form, this.companyIn);
								let shi = this.cityOptions.find(item => item.mingcheng == this.form.shi)
								let qu = shi.children.find(item => item.mingcheng == this.form.qu)
								this.form.cityText = shi.mingcheng + ' ' + qu.mingcheng;
							}
						}
					})
					.catch(err => {console.log('数据加载失败！', err);this.disabled = true;})
			},
			// async getCity(){
			// 	await vk.callFunction({
			// 		url: 'client/sakj/pub.lhfj.getCityTree'
			// 	})
			// 	.then(res => {
			// 		this.cityOptions = res.data;
			// 	})
			// },
			// 选中城市
			confirmCity(e){
				this.form.shi = e[0].label;
				this.form.qu = e[1].label;
				this.form.cityText = e[0].label + ' ' + e[1].label;
			},
			getCompanyList(){
				if(!this.query.companyName){
					vk.toast('请先输入关键字再进行搜索');
					return
				}
				this.query.pageNum = 0;
				this.query.pageSize = 1000;
				this.query.username = this.query.companyName
				this.companyList = [];
				
				this.$util.request(this.$api.CompanyList, this.query)
					.then(res => {
						// console.log('申报列表', res);
						this.companyList = res.rows;
					})
			},
			chooseCompany(company){
				this.form.companyId      = company.id     
				this.form.companyName    = company.username   
				this.form.xukezhenghao   = company.xukezhenghao  
				this.form.contactName    = company.lianxiren   
				this.form.contactTel     = company.lianxirentel    
				this.form.companyAddress = company.jingyingdizhi
				this.form.shi            = company.shi           
				this.form.qu             = company.qu            
				
				let shi = this.cityOptions.find(item => item.mingcheng == this.form.shi)
				let qu = shi.children.find(item => item.mingcheng == this.form.qu)
				this.form.cityText = shi.mingcheng + ' ' + qu.mingcheng;
				
				this.showCompanyDialog = false
			},
			submit() {
				if(config.debug) console.log('验证form', this.form);
				
				this.disabled = true;
				this.loading = true;
				this.$refs.uForm.validate(valid => {
					if (valid) {
						// 处理管理模式文字字段
						if (this.form.guanlimoshi == 0) {
							this.form.guanlimoshiname = this.guanlimoshiFormat({
								guanlimoshi: this.form.guanlimoshi,
							});
						}
						// 处理管理团队文字字段
						this.form.guanlituanduiname = '';
						if(this.form.guanlituandui.length > 0){
							this.form.guanlituandui.forEach((item) => {
								this.form.guanlituanduiname +=
									this.guanlituanduiFormat({
										guanlituandui: item,
									}) + ',';
							});
							if (this.form.guanlituanduiname.length > 0) {
								this.form.guanlituanduiname = this.form.guanlituanduiname.substring(
									0,
									this.form.guanlituanduiname.length - 1
								);
							}
						}
						// guanlituandui多选框数组转成字符串
						this.form.guanlituandui = this.form.guanlituandui.toString();
						
						// 处理22个选项文字字段
						for (let i = 1; i <= 22; i++) {
							if (i == 2) continue;
							if (this.form['itemkey' + i] == 0)
								this.form['itemname' + i] = this['itemkey' + i + 'Format']({
									['itemkey' + i]: this.form['itemkey' + i],
								});
						}

						// console.log('form', this.form);
						
						this.submitForm();
					} else {
						this.disabled = false;
						this.loading = false;
					}
				});
			},
			submitForm(){
				vk.setVuex('$lhfj.business', null);
				
				let method = this.id ? 'PUT' : 'POST';
				this.$util.request(this.$api.BusinessRestful, this.form, method)
					.then(res => {
						if (res.code === 200) {
							vk.toast("保存成功", "success", 1000, true, () => {
								const eventChannel = this.getOpenerEventChannel();
								if (eventChannel.emit) eventChannel.emit('refresh');
								vk.navigateBack();
							});
						} else {
							console.log('保存失败', res)
							this.disabled = false;
							this.loading = false;
							vk.alert(res.msg, '保存失败');
						}
					}).catch((err) => {
						console.log('保存异常', err)
						this.disabled = false;
						this.loading = false;
						vk.alert(JSON.stringify(err), '保存异常');
					})
			},
			// 选择图片后触发
			chooseComplete(lists, name){
				if(!this.$util.getToken()){
					this.$util.toLogin(()=>this.initPage())
				}
			},
			// 图片上传成功时触发
			uploadSuccess(data, index, lists, name){
				console.log('图片上传成功', data, index, lists, name)
				// this.fileList = lists
			},
			// 图片上传失败时触发
			uploadError(data, index, lists, name){
				console.log('图片上传失败', data, index, lists, name)
			},
			// 所有图片上传完毕触发
			uploaded(lists, name){
				console.log('全部图片上传完成', lists, name)
				this.fileList = lists
			}
		},
		watch: {
			// form(newVal, oldVal) {
			// 	console.log('form的值发生改变', newVal, oldVal, this.form);
			// 	// 监听文本框值的改变
			// 	if (newVal !== oldVal) {
			// 		// 执行需要在文本框值改变时执行的方法
			// 		console.log('文本框的值发生改变');
			// 		// 调用其他方法
			// 		// this.otherMethod();
			// 	}
			// }
			form: {
				handler(newVal, oldVal) {
					// 修改时，不保留缓存
					if(this.form.id) return
					
					// 防抖，一定时间内不操作，才执行
					vk.pubfn.debounce(() => {
						console.log('form的值发生改变', newVal, oldVal, this.form)
						vk.setVuex('$lhfj.business', newVal);
					}, 1000, false, "id1");
				},
				deep: true,
			}
		},
	}
</script>

<style>
	.form {
		margin: auto;
		width: 90%;
	}
	.split-line{
		width: 100%;
		height: 8rpx;
		border-bottom: 1px dashed #e1e1e1;
	}
</style>